package com.cssw.fyzb.busi.api.video;

import com.cssw.fyzb.core.model.vo.video.VideoHotDefVo;
import com.cssw.fyzb.busi.service.video.VideoService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 查询热门定价列表
 *
 * @author YangYiQun
 */
@Function(description = "查询热门定价列表", parameters = {
}, result = @Result(
        properties = {
                @Property(name = "total", type = Type.Integer, description = "总页数"),
                @Property(name = "count", type = Type.Integer, description = "总行数"),

        },
        listProperties = {
                @ListProperty(name = "list", properties = {
                        @Property(name = "hotId", type = Type.Integer, description = "热点标识"),
                        @Property(name = "hotValue", type = Type.Integer, description = "热点值"),
                        @Property(name = "hotName", type = Type.String, description = "热点名称"),
                        @Property(name = "hotOprCode", type = Type.String, description = "投放位置编码"),
                        @Property(name = "price", type = Type.String, description = "果子价格"),
                        @Property(name = "hotOprName", type = Type.String, description = "投放位置名称"),
                        @Property(name = "hotTime", type = Type.Integer, description = "投放时长（小时）")
                })
        }
))
@Component
public class ListVideoHotDef implements Action {

    @Autowired
    private VideoService videoService;

    private static final Logger logger = LoggerFactory.getLogger(ListVideoHotDef.class);

    @Override
    public Response execute(Request request) throws Exception {

        try {
            List<VideoHotDefVo> list = videoService.listHotDef();
            return Response.success().put("list", list).put("total", list.size()).put("count", list.size());
        } catch (Exception e) {
            logger.info("", e);
            return Response.fail("操作异常");
        }
    }

}
